//
//  ST_TIANEmojiTaskComponent.swift
//  btvideo
//
//  Created by Jason on 2021/11/2.
//  Copyright © 2021 JarvanZhang. All rights reserved.
//

import Foundation
import RxSwift
import RxCocoa

class ST_TIANEmojiTaskComponent {
    
    private let emojiObservable = BehaviorRelay<[ST_EmojiGroupModel]>(value: [])
    
}

extension ST_TIANEmojiTaskComponent{
    
    func fetch_collection_emoji() -> BehaviorRelay<[ST_EmojiGroupModel]> {
        
        if emojiObservable.value.count < 1 {
            
            JVrequest(PH.fetchEmojiPackageApi, success: { (json) in
            
                
                
                let list  = json["data"].arrayValue.map { (itemJson) -> ST_EmojiGroupModel in
                    return ST_EmojiGroupModel.init(fromJson: itemJson)
                }
                
                self.emojiObservable.accept(list)
                
                print("获取表情包",json)
                
            }) { (code, err) in
                
                print("获取表情包错误:",err)
            }
        }
        return emojiObservable
    }
    
}
